<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>西瓜后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/car_maintain.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-header">选择配置方式</div>
        <div class="layui-card-body">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">车辆配置<span class="layui-text-red">*</span> </label>
                    <div class="layui-input-block">
                        <div class="param_btn_container">
                            <a class="layui-btn layui-bg-green" id="file_choose">选择附件</a>
                            <a class="layui-btn layui-bg-blue" id="file_btn">开始上传</a><br/>
                            <a class="layui-btn layui-btn-border">下载file模板</a>
                            <a class="layui-btn layui-btn-border">手动录入</a>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">

                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="layui-card">
        <form class="layui-form">
            <div class="param_box_wrap">
                <div class="layui-header">基本参数</div>
                <div class="layui-card-body">
                    <div class="param_add"><i class="layui-icon layui-icon-add-1"></i>添加 </div>
                    <div class="param_add_box_wrap"></div>
                </div>
            </div>
            <div class="param_box_wrap">
                <div class="layui-header">车身参数</div>
                <div class="layui-card-body">
                    <div class="param_add"><i class="layui-icon layui-icon-add-1"></i>添加 </div>
                    <div class="param_add_box_wrap"></div>
                </div>
            </div>
            <div class="param_box_wrap">
                <div class="layui-header">电动机</div>
                <div class="layui-card-body">
                    <div class="param_add"><i class="layui-icon layui-icon-add-1"></i>添加 </div>
                    <div class="param_add_box_wrap"></div>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="../../../layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
        list: 'car_source/list', //list模块
    }).use(['index','list','form','jquery','upload'],function () {
        var $ = layui.$
            ,upload = layui.upload
            ,form = layui.form;
        upload.render({
            elem: '#file_choose'
            ,url: '/upload/'
            ,auto: false
            ,accept: 'file'
            ,bindAction: '#file_btn'
            ,done: function(res){
                console.log(res)
            }
        });
        $(".param_add").each(function () {
            $(this).click(function () {
                paramAdd($(this));
                form.render();
            })
        })
        var paramData = ['参数1','参数2'];
        function paramAdd(obj) {
            var param_add_box ='<form class="layui-form">' +
                '                   <div class="param_add_box">\n' +
                '                        <div class="layui-input-inline layui-col-space20">\n' +
                '                            <div class="layui-input-inline">\n' +
                '                                <select class="layui-select" name="maintain_base_choose_param">\n' +
                '                                </select>\n' +
                '                            </div>\n' +
                '                            <div class="layui-input-inline">\n' +
                '                                <input class="layui-input" name="maintain_base_param" value=""/>\n' +
                '                            </div>\n' +
                '                            <div class="layui-input-inline">\n' +
                '                                <input type="checkbox" checked="" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="是|否"><span>点亮数据</span>\n' +
                '                            </div>\n' +
                '                        </div>\n' +
                '                        <div class="layui-input-inline">\n' +
                '                            <a href="javascript:;" class="layui-text-red param_del" onclick="this.parentNode.parentNode.remove(this);">删除</a>\n' +
                '                        </div>\n' +
                '                    </div>\n' +
                '                </div>' +
                '             </form>';
            obj.parent().find(".param_add_box_wrap").append(param_add_box);
            var param_select = obj.parent().find("select[name=maintain_base_choose_param]");
            param_select.empty();
            for(var i=0;i<paramData.length;i++){
                param_select.append("<option>"+paramData[i]+"</option>")
            }
        }
        form.render();
    });
</script>
</body>
</html>